<template>
  <vxe-modal
    v-model="showEdit"
    :title="title"
    :width="modalWidth"
    min-width="600"
    min-height="300"
    :loading="submitLoading"
    :show-zoom="true"
    destroy-on-close>
    <template #default>
      <permission-form ref="form" :is-modal="title" @modalControl="modalControl"></permission-form>
    </template>
  </vxe-modal>
</template>

<script>
import PermissionForm from '@/views/system/PermissionManagement/modules/PermissionForm'

export default {
  name: 'PermissionModal',
  components: { PermissionForm },
  // 监听 数据改变
  // watch: {
  //   insertTableData (newValue) {
  //     console.log('2', newValue)
  //     this.$emit('insertTableData', newValue)
  //   }
  // },
  data () {
    return {
      modalWidth: 800,
      selectRow: null,
      showEdit: false,
      submitLoading: false,
      title: ''
    }
  },
  methods: {
    modalControl (val) {
      // console.log(val)
      if (val.submitLoading != null) {
        this.submitLoading = val.submitLoading
      }
      if (val.showEdit != null) {
        this.showEdit = val.showEdit
      }
    },
    add () {
      this.showEdit = true
      this.$nextTick(() => {
        this.$refs.form.add()
        this.$refs.form.disabledSubmit = false
      })
    },
    edit (row) {
      this.showEdit = true
      this.$nextTick(() => {
        this.$refs.form.edit(row)
        this.$refs.form.disabledSubmit = false
      })
    },
    addSub (row) {
      this.showEdit = true
      this.$nextTick(() => {
        this.$refs.form.addSub(row)
        this.$refs.form.disabledSubmit = false
      })
    },
    Detail (row) {
      this.showEdit = true
      this.$nextTick(() => {
        this.$refs.form.Detail(row)
        this.$refs.form.disabledSubmit = true
      })
    }
  }
}
</script>

<style scoped>

</style>
